1. Field of the Invention
This invention relates in general to memory management and programming techniques performed by computers, and in particular, to a method, apparatus, and article of manufacture for passing of arrays to stored procedures.
2. Description of Related Art
Stored procedures are collections of pre-defined procedural code that typically employ SQL to access databases. There are a number of benefits in using stored procedures, including function encapsulation, performance enhancement, client-server processing, and security. Stored procedures are not unlike procedures found in other high level languages, in that they can be passed input and output parameters. Generally, stored procedures may take any number of parameters, which are defined internally within the procedure.
Generally, a programmer explicitly invokes stored procedures in an interactive environment, but such procedures can also be executed or invoked by other programs. However, there may be a problem in passing parameters between an invoking program and a stored procedure because of the differences in the format of the data recognized by each.
For example, a common structure for representing data is an array. An array is a set of pairs, corresponding to an index and a value. Arrays are typically implemented as a consecutive set of memory locations, which facilities the calculation of an index and corresponding value pair. Often, it is desirable to pass arrays to stored procedures.
A problem arises, however, in passing VisualBasic arrays to SQL stored procedures. VisualBasic stores arrays as objects, and these objects do not conform to parameter passing standards for SQL stored procedures. Stored procedures generally expect to be provided with a handle for the array.
Handles refer to objects that are managed by the Microsoft Windows environment. Handles comprise a 32-bit integer value that identifies an object in a WIN32 environment (or alternatively, a 16-bit integer value in a WIN16 environment). The use of handles insulates the application from various aspects of object management. However, not only are there many different types of objects, but they differ dramatically in how they are used and the types of requirements and restrictions that one must follow when using them.
Passing an array from a VisualBasic program to an SQL stored procedure is problematic, because the SQL stored procedure does not recognize the VisualBasic array structure. Thus, passing VisualBasic arrays to SQL stored procedures can lead to compiler errors, or erroneous results resulting from invalid conversions or alignment problems. Therefore, there is a need in the art for a way to pass an array from VisualBasic to an SQL stored procedure.